package com.bus.core.entity.base;

import java.io.Serializable;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.MapKeyColumn;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;


/**
 * This is an object that contains data related to the jc_user table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="jc_user"
 */
@MappedSuperclass
public abstract class BaseBusUser  implements Serializable {

	public static String REF = "BusUser";
	public static String PROP_REGISTER_TIME = "registerTime";
	public static String PROP_LOGIN_COUNT = "loginCount";
	public static String PROP_SELF_ADMIN = "selfAdmin";
	public static String PROP_UPLOAD_TOTAL = "uploadTotal";
	public static String PROP_LAST_LOGIN_IP = "lastLoginIp";
	public static String PROP_DISABLED = "disabled";
	public static String PROP_LAST_LOGIN_TIME = "lastLoginTime";
	public static String PROP_UPLOAD_DATE = "uploadDate";
	public static String PROP_GROUP = "group";
	public static String PROP_EMAIL = "email";
	public static String PROP_UPLOAD_SIZE = "uploadSize";
	public static String PROP_RANK = "rank";
	public static String PROP_VIEWONLY_ADMIN = "viewonlyAdmin";
	public static String PROP_ADMIN = "admin";
	public static String PROP_ID = "id";
	public static String PROP_REGISTER_IP = "registerIp";
	public static String PROP_USERNAME = "username";


	// constructors
	public BaseBusUser () {
		initialize();
	}

	/**
	 * Constructor for primary key
	 */
	public BaseBusUser (java.lang.Integer id) {
		this.setId(id);
		initialize();
	}

	/**
	 * Constructor for required fields
	 */
	public BaseBusUser (
		java.lang.Integer id,
		java.lang.String username,
		java.util.Date registerTime,
		java.lang.String registerIp,
		java.lang.Integer loginCount,
		java.lang.Integer rank,
		java.lang.Long uploadTotal,
		java.lang.Integer uploadSize,
		java.lang.Boolean admin,
		java.lang.Boolean viewonlyAdmin,
		java.lang.Boolean selfAdmin,
		java.lang.Integer statu) {

		this.setId(id);
		this.setUsername(username);
		this.setRegisterTime(registerTime);
		this.setRegisterIp(registerIp);
		this.setLoginCount(loginCount);
		this.setRank(rank);
		this.setUploadTotal(uploadTotal);
		this.setUploadSize(uploadSize);
		this.setAdmin(admin);
		this.setViewonlyAdmin(viewonlyAdmin);
		this.setSelfAdmin(selfAdmin);
		this.setStatu(statu);
		initialize();
	}

	protected void initialize () {}



	@Transient
	private int hashCode = Integer.MIN_VALUE;

	// primary key
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="user_id")
	private java.lang.Integer id;

	// fields
	@Column(name="username")
	private java.lang.String username;
	@Column(name="email")
	private java.lang.String email;
	@Column(name="register_time")
	private java.util.Date registerTime;
	@Column(name="register_ip")
	private java.lang.String registerIp;
	@Temporal(TemporalType.TIMESTAMP)
	private java.util.Date lastLoginTime;
	@Column(name="last_login_ip")
	private java.lang.String lastLoginIp;
	@Column(name="login_count")
	private java.lang.Integer loginCount;
	@Column(name="rank")
	private java.lang.Integer rank;
	@Column(name="upload_total")
	private java.lang.Long uploadTotal;
	@Column(name="upload_size")
	private java.lang.Integer uploadSize;
	@Column(name="upload_date")
	private java.sql.Date uploadDate;
	@Column(name="is_admin")
	private java.lang.Boolean admin;
	@Column(name="is_viewonly_admin")
	private java.lang.Boolean viewonlyAdmin;
	@Column(name="is_self_admin")
	private java.lang.Boolean selfAdmin;
	@Column(name="statu")
	private java.lang.Integer statu;
	@Column(name="session_id")
	private java.lang.String sessionId;

	// collections
	@ElementCollection
	@Cascade(CascadeType.DELETE)
	@CollectionTable(name="jc_user_attr")
	@MapKeyColumn(name="attr_name")
	private java.util.Map<java.lang.String, java.lang.String> attr;
	
	@OneToMany(fetch=FetchType.EAGER)
	@Cascade(CascadeType.DELETE)
	@JoinColumn(name="user_id")
	private java.util.Set<com.bus.core.entity.BusUserExt> userExtSet;
	
	@OneToMany(fetch=FetchType.EAGER)
	@Cascade(CascadeType.DELETE)
	@JoinColumn(name="user_id")
	private java.util.Set<com.bus.core.entity.BusUserSite> userSites;
	
	
	/**
	 * Return the unique identifier of this class
     * @hibernate.id
     *  generator-class="assigned"
     *  column="user_id"
     */
	public java.lang.Integer getId () {
		return id;
	}

	/**
	 * Set the unique identifier of this class
	 * @param id the new ID
	 */
	public void setId (java.lang.Integer id) {
		this.id = id;
		this.hashCode = Integer.MIN_VALUE;
	}




	/**
	 * Return the value associated with the column: username
	 */
	public java.lang.String getUsername () {
		return username;
	}

	/**
	 * Set the value related to the column: username
	 * @param username the username value
	 */
	public void setUsername (java.lang.String username) {
		this.username = username;
	}


	/**
	 * Return the value associated with the column: email
	 */
	public java.lang.String getEmail () {
		return email;
	}

	/**
	 * Set the value related to the column: email
	 * @param email the email value
	 */
	public void setEmail (java.lang.String email) {
		this.email = email;
	}


	/**
	 * Return the value associated with the column: register_time
	 */
	public java.util.Date getRegisterTime () {
		return registerTime;
	}

	/**
	 * Set the value related to the column: register_time
	 * @param registerTime the register_time value
	 */
	public void setRegisterTime (java.util.Date registerTime) {
		this.registerTime = registerTime;
	}


	/**
	 * Return the value associated with the column: register_ip
	 */
	public java.lang.String getRegisterIp () {
		return registerIp;
	}

	/**
	 * Set the value related to the column: register_ip
	 * @param registerIp the register_ip value
	 */
	public void setRegisterIp (java.lang.String registerIp) {
		this.registerIp = registerIp;
	}


	/**
	 * Return the value associated with the column: last_login_time
	 */
	public java.util.Date getLastLoginTime () {
		return lastLoginTime;
	}

	/**
	 * Set the value related to the column: last_login_time
	 * @param lastLoginTime the last_login_time value
	 */
	public void setLastLoginTime (java.util.Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}


	/**
	 * Return the value associated with the column: last_login_ip
	 */
	public java.lang.String getLastLoginIp () {
		return lastLoginIp;
	}

	/**
	 * Set the value related to the column: last_login_ip
	 * @param lastLoginIp the last_login_ip value
	 */
	public void setLastLoginIp (java.lang.String lastLoginIp) {
		this.lastLoginIp = lastLoginIp;
	}


	/**
	 * Return the value associated with the column: login_count
	 */
	public java.lang.Integer getLoginCount () {
		return loginCount;
	}

	/**
	 * Set the value related to the column: login_count
	 * @param loginCount the login_count value
	 */
	public void setLoginCount (java.lang.Integer loginCount) {
		this.loginCount = loginCount;
	}


	/**
	 * Return the value associated with the column: rank
	 */
	public java.lang.Integer getRank () {
		return rank;
	}

	/**
	 * Set the value related to the column: rank
	 * @param rank the rank value
	 */
	public void setRank (java.lang.Integer rank) {
		this.rank = rank;
	}


	/**
	 * Return the value associated with the column: upload_total
	 */
	public java.lang.Long getUploadTotal () {
		return uploadTotal;
	}

	/**
	 * Set the value related to the column: upload_total
	 * @param uploadTotal the upload_total value
	 */
	public void setUploadTotal (java.lang.Long uploadTotal) {
		this.uploadTotal = uploadTotal;
	}


	/**
	 * Return the value associated with the column: upload_size
	 */
	public java.lang.Integer getUploadSize () {
		return uploadSize;
	}

	/**
	 * Set the value related to the column: upload_size
	 * @param uploadSize the upload_size value
	 */
	public void setUploadSize (java.lang.Integer uploadSize) {
		this.uploadSize = uploadSize;
	}


	/**
	 * Return the value associated with the column: upload_date
	 */
	public java.sql.Date getUploadDate () {
		return uploadDate;
	}

	/**
	 * Set the value related to the column: upload_date
	 * @param uploadDate the upload_date value
	 */
	public void setUploadDate (java.sql.Date uploadDate) {
		this.uploadDate = uploadDate;
	}


	/**
	 * Return the value associated with the column: is_admin
	 */
	public java.lang.Boolean getAdmin () {
		return admin;
	}

	/**
	 * Set the value related to the column: is_admin
	 * @param admin the is_admin value
	 */
	public void setAdmin (java.lang.Boolean admin) {
		this.admin = admin;
	}


	/**
	 * Return the value associated with the column: is_viewonly_admin
	 */
	public java.lang.Boolean getViewonlyAdmin () {
		return viewonlyAdmin;
	}

	/**
	 * Set the value related to the column: is_viewonly_admin
	 * @param viewonlyAdmin the is_viewonly_admin value
	 */
	public void setViewonlyAdmin (java.lang.Boolean viewonlyAdmin) {
		this.viewonlyAdmin = viewonlyAdmin;
	}


	/**
	 * Return the value associated with the column: is_self_admin
	 */
	public java.lang.Boolean getSelfAdmin () {
		return selfAdmin;
	}

	/**
	 * Set the value related to the column: is_self_admin
	 * @param selfAdmin the is_self_admin value
	 */
	public void setSelfAdmin (java.lang.Boolean selfAdmin) {
		this.selfAdmin = selfAdmin;
	}

	public java.lang.Integer getStatu() {
		return statu;
	}

	public void setStatu(java.lang.Integer statu) {
		this.statu = statu;
	}
	
	
	public java.lang.String getSessionId() {
		return sessionId;
	}

	public void setSessionId(java.lang.String sessionId) {
		this.sessionId = sessionId;
	}


	public java.util.Map<java.lang.String, java.lang.String> getAttr() {
		return attr;
	}

	public void setAttr(java.util.Map<java.lang.String, java.lang.String> attr) {
		this.attr = attr;
	}

	/**
	 * Return the value associated with the column: userExtSet
	 */
	public java.util.Set<com.bus.core.entity.BusUserExt> getUserExtSet () {
		return userExtSet;
	}

	/**
	 * Set the value related to the column: userExtSet
	 * @param userExtSet the userExtSet value
	 */
	public void setUserExtSet (java.util.Set<com.bus.core.entity.BusUserExt> userExtSet) {
		this.userExtSet = userExtSet;
	}
	
	/**
	 * Return the value associated with the column: userSites
	 */
	public java.util.Set<com.bus.core.entity.BusUserSite> getUserSites () {
		return userSites;
	}

	/**
	 * Set the value related to the column: userSites
	 * @param userSites the userSites value
	 */
	public void setUserSites (java.util.Set<com.bus.core.entity.BusUserSite> userSites) {
		this.userSites = userSites;
	}

	public boolean equals (Object obj) {
		if (null == obj) return false;
		if (!(obj instanceof com.bus.core.entity.BusUser)) return false;
		else {
			com.bus.core.entity.BusUser busUser = (com.bus.core.entity.BusUser) obj;
			if (null == this.getId() || null == busUser.getId()) return false;
			else return (this.getId().equals(busUser.getId()));
		}
	}

	public int hashCode () {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (null == this.getId()) return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}
		return this.hashCode;
	}


	public String toString () {
		return super.toString();
	}


}